package com.szp.lagou.dubbo.filerDemo.provider.service;

import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Random;

@Service
public class DemoServiceImpl implements DemoService {
    Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class);
    @Override
    public String methodA(String word) {
//        logger.info("从RpcContext中获取到客户端ip为:" + clientIp);
        Random random = new Random();
        int i = random.nextInt(101);
        try {
            Thread.currentThread().sleep(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("接受到调用，参数:" + word + " " +System.currentTimeMillis());
        return "Provider1 "+ " methodA " +word;
    }

    @Override
    public String methodB(String word){
        Random random = new Random();
        int i = random.nextInt(101);
        try {
            Thread.currentThread().sleep(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("接受到调用，参数:" + word + " " +System.currentTimeMillis());
        return "Provider1 "+ " methodB " +word;
    }

    @Override
    public String methodC(String word) {
        Random random = new Random();
        int i = random.nextInt();
        try {
            Thread.currentThread().sleep(101);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("接受到调用，参数:" + word + " " +System.currentTimeMillis());
        return "Provider1 "+ " methodC " +word;
    }
}
